package com.example.petadopt.dao;

import com.example.petadopt.entity.AdoptionApplication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

public interface AdoptionApplicationDao extends JpaRepository<AdoptionApplication,Integer> {
}
//@Repository
//public class AdoptionApplicationDao {
//
//    private final JdbcTemplate jdbcTemplate;
//
//    @Autowired
//    public AdoptionApplicationDao(JdbcTemplate jdbcTemplate) {
//        this.jdbcTemplate = jdbcTemplate;
//    }
//
//    // 保存领养申请记录
//    public void save(AdoptionApplication application) {
//        String sql = "INSERT INTO adopt_apply (adopt_pet_id, adopt_user_id, applicant_name, adopt_email, adopt_phone, adopt_address, adopt_date, adopt_reason) " +
//                "VALUES (?,?,?,?,?,?,?,?)";
//        jdbcTemplate.update(sql,
//                application.getAdoptPetId(),
//                application.getAdoptUserId(),
//                application.getApplicantName(),
//                application.getAdoptEmail(),
//                application.getAdoptPhone(),
//                application.getAdoptAddress(),
//                application.getAdoptDate(),
//                application.getAdoptReason()
//        );
//    }
//
//    // 根据用户ID查询该用户的领养申请记录
//    public List<AdoptionApplication> findByAdoptUserId(int adoptUserId) {
//        String sql = "SELECT * FROM adopt_apply WHERE adopt_user_id =?";
//        return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(AdoptionApplication.class), adoptUserId);
//    }
//
//    // 根据宠物ID查询与该宠物相关的领养申请记录
//    public List<AdoptionApplication> findByAdoptPetId(int adoptPetId) {
//        String sql = "SELECT * FROM adopt_apply WHERE adopt_pet_id =?";
//        return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(AdoptionApplication.class), adoptPetId);
//    }
//}